package com.briup.mt.service.impl;

import com.briup.mt.bean.BaseConfig;
import com.briup.mt.bean.BaseConfigExample;
import com.briup.mt.bean.BaseLog;
import com.briup.mt.bean.BaseLogExample;
import com.briup.mt.dao.BaseConfigMapper;
import com.briup.mt.dao.BaseLogMapper;
import com.briup.mt.service.IBaseLogService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BaseLogServiceImpl implements IBaseLogService {

    @Resource
    private BaseLogMapper baseLogMapper;

    @Override
    public List<BaseLog> query(String realname) {

        BaseLogExample baseLogExample = new BaseLogExample();
        if(!StringUtils.isEmpty(realname)){
            baseLogExample.createCriteria().andRealnameLike("%"+realname+"%");
        }

        List<BaseLog> list = baseLogMapper.selectByExample(baseLogExample);
        return list;
    }
    @Override
    public void saveOrUpdate(BaseLog baseLog) {
        if(baseLog.getId() == null){
            baseLogMapper.insert(baseLog);
        } else {
            baseLogMapper.updateByPrimaryKey(baseLog);
        }
    }

    @Override
    public void deleteById(long id) {
        baseLogMapper.deleteByPrimaryKey(id);

    }

}
